<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>4.2定位布局</title>
  <style>
    .box1{
      width: 100%;
      height: 300px;
      border: 1px solid red;
      position: relative;/*相对于原来的位置偏移*/
      top: 0px;
      left: 0px;
    }
    .box1 .item1 {
      width: 100px;
      height: 60px;
      background: blanchedalmond;
      position: relative;
      top: 10px;
      z-index: 2;
    }
    .box1 .item2 {
      z-index: 1;
      width: 100px;
      height: 60px;
      background: blue;
      position: relative;
      top: -40px;
      left: 30px
    }
    .box2{
      width: 100%;
      height: 300px;
      border: 1px solid red;
      position: relative;
    }
    .box2 .item1 {
      width: 100px;
      height: 60px;
      background: blanchedalmond;
      position: absolute;/*绝对定位*/
      top: 0px;
      left: 0px;
    }
    .box2 .item2 {
      width: 100px;
      height: 60px;
      background: blue;
      position: absolute;/*绝对定位*/
      top: 30px;
      left: 20px;
    }
    .box3{
      width: 200px;
      height: 60px;
      background:red;
      position: fixed;
      top: 100px;
      left: 200px;
    }
  </style>
</head>
<body>
  <h3>相对定位</h3>
  <div class="box1">
    <div class="item1"></div>
    <div class="item2"></div>
  </div>
  <h3>绝对定位</h3>
  <div class="box2">
    <div class="item1"></div>
    <div class="item2"></div>
  </div>
  <h3>固定定位</h3>
  <div class="box3">

  </div>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
  <p>我是段落</p>
</body>
</html>